home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Container / Sources / Content.cpp < prev    next >
Encoding:
Text File  |  1996-12-16  |  22.0 KB  |  748 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Content.cpp
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "Container.hpp"
  11.  
  12. #ifndef CONTENT_H
  13. #include "Content.h"
  14. #endif
  15.  
  16. #ifndef PART_H
  17. #include "Part.h"
  18. #endif
  19.  
  20. #ifndef SELECT_H
  21. #include "Select.h"
  22. #endif
  23.  
  24. // ----- Part Layer -----
  25.  
  26. #ifndef FWUTIL_H
  27. #include "FWUtil.h"
  28. #endif
  29.  
  30. #ifndef FWPRESEN_H
  31. #include "FWPresen.h"
  32. #endif
  33.  
  34. #ifndef FWFCTCLP_H
  35. #include "FWFctClp.h"
  36. #endif
  37.  
  38. #ifndef FWKIND_H
  39. #include "FWKind.h"
  40. #endif
  41.  
  42. // ----- OS Layer -----
  43.  
  44. #ifndef FWRECT_H
  45. #include "FWRect.h"
  46. #endif
  47.  
  48. #ifndef FWODGEOM_H
  49. #include "FWODGeom.h"
  50. #endif
  51.  
  52. #ifndef FWSUSINK_H
  53. #include "FWSUSink.h"
  54. #endif
  55.  
  56. #ifndef FWBARRAY_H
  57. #include "FWBArray.h"
  58. #endif
  59.  
  60. // ----- Foundation Layer -----
  61.  
  62. #ifndef FWSTREAM_H
  63. #include "FWStream.h"
  64. #endif
  65.  
  66. #ifndef FWSUSINK_H
  67. #include "FWSUSink.h"
  68. #endif
  69.  
  70. #ifndef FWMEMORY_H
  71. #include "FWMemory.h"
  72. #endif
  73.  
  74. // ----- OpenDoc Includes -----
  75.  
  76. #ifndef SOM_Module_OpenDoc_StdProps_defined
  77. #include <StdProps.xh>
  78. #endif
  79.  
  80. #ifndef SOM_ODShape_xh
  81. #include <Shape.xh>
  82. #endif
  83.  
  84. #ifndef SOM_ODStorageUnit_xh
  85. #include <StorageU.xh>
  86. #endif
  87.  
  88. //========================================================================================
  89. // Runtime Information
  90. //========================================================================================
  91.  
  92. #ifdef FW_BUILD_MAC
  93. #pragma segment odfcontainer
  94. #endif
  95.  
  96. FW_DEFINE_AUTO(CBaseContent)
  97. FW_DEFINE_AUTO(CPartContent)
  98. FW_DEFINE_AUTO(CSelectionContent)
  99. FW_DEFINE_AUTO(CUndoContent)
  100. FW_DEFINE_AUTO(CContentProxyIterator)
  101.  
  102. #ifdef __MRC__
  103. // This is to go around a bug in MRC. It doesn't seems to see the extern
  104. // in Iters.cpp
  105. FW_DEFINE_AUTO_TEMPLATE(FW_TRefCountedCollection, CProxy)
  106. #endif
  107.  
  108. //========================================================================================
  109. //    class CBaseContent
  110. //========================================================================================
  111.  
  112. //----------------------------------------------------------------------------------------
  113. //    CBaseContent::CBaseContent
  114. //----------------------------------------------------------------------------------------
  115. //    CBaseContent constructor
  116.  
  117. CBaseContent::CBaseContent(Environment* ev, CContainerPart* part) :
  118.     FW_CContent(ev, part),
  119.     fProxyList(NULL),
  120.     fContainerPart(part),
  121.     fBackgroundColor(56000, 56000, 65535)    // light blue
  122. {
  123.     fProxyList = FW_NEW(CProxyCollection, ());
  124.     
  125.     FW_END_CONSTRUCTOR
  126. }
  127.  
  128. //----------------------------------------------------------------------------------------
  129. //    CBaseContent::CBaseContent
  130. //----------------------------------------------------------------------------------------
  131.  
  132. CBaseContent::CBaseContent(Environment* ev, CBaseContent* other) :
  133.     FW_CContent(ev, other->fContainerPart),
  134.     fProxyList(NULL),
  135.     fContainerPart(other->fContainerPart),
  136.     fBackgroundColor(other->fBackgroundColor)
  137. {
  138.     fProxyList = FW_NEW(CProxyCollection, ());
  139.  
  140.     CContentProxyIterator ite(other);
  141.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  142.     {
  143.         this->AddProxy(ev, proxy);
  144.     }
  145.  
  146.     FW_END_CONSTRUCTOR
  147. }
  148.  
  149. //----------------------------------------------------------------------------------------
  150. //    CBaseContent::~CBaseContent
  151. //----------------------------------------------------------------------------------------
  152. //    CBaseContent destructor
  153.  
  154. CBaseContent::~CBaseContent()
  155. {
  156.     FW_START_DESTRUCTOR
  157.     delete fProxyList;
  158. }
  159.  
  160. //----------------------------------------------------------------------------------------
  161. //    CBaseContent::AddProxy
  162. //----------------------------------------------------------------------------------------
  163.  
  164. void CBaseContent::AddProxy(Environment* ev, CProxy* proxy)
  165. {
  166. FW_UNUSED(ev);
  167.     fProxyList->AddLast(proxy);
  168. }
  169.  
  170. //----------------------------------------------------------------------------------------
  171. //    CBaseContent::RemoveProxy
  172. //----------------------------------------------------------------------------------------
  173.  
  174. void CBaseContent::RemoveProxy(Environment* ev, CProxy* proxy)
  175. {
  176. FW_UNUSED(ev);
  177.     fProxyList->RemoveAndRelease(proxy);
  178. }
  179.  
  180. //----------------------------------------------------------------------------------------
  181. //    CBaseContent::CountProxies
  182. //----------------------------------------------------------------------------------------
  183.  
  184. unsigned long CBaseContent::CountProxies() const
  185. {
  186.     return fProxyList->Count();
  187. }
  188.  
  189. //----------------------------------------------------------------------------------------
  190. //    CBaseContent::GetFirstProxy
  191. //----------------------------------------------------------------------------------------
  192.  
  193. CProxy* CBaseContent::GetFirstProxy() const
  194. {
  195.     return fProxyList->First();
  196. }
  197.  
  198. //----------------------------------------------------------------------------------------
  199. //    CBaseContent::IsEmpty
  200. //----------------------------------------------------------------------------------------
  201.  
  202. FW_Boolean CBaseContent::IsEmpty() const
  203. {
  204.     return (fProxyList->Count() == 0);
  205. }
  206.  
  207. //----------------------------------------------------------------------------------------
  208. //    CBaseContent::CalcUpdateShape
  209. //----------------------------------------------------------------------------------------
  210.  
  211. ODShape* CBaseContent::CalcUpdateShape(Environment* ev)
  212. {
  213.     if (this->IsEmpty())
  214.         return NULL;
  215.  
  216.     ODShape* updateShape = ::FW_NewODShape(ev);
  217.  
  218.     FW_CAcquiredODShape aqTempShape = ::FW_NewODShape(ev);
  219.     FW_Boolean first = TRUE;
  220.  
  221.     CContentProxyIterator ite(this);
  222.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  223.     {
  224.         proxy->GetUpdateBox(ev, aqTempShape);
  225.         if (first)
  226.             updateShape->CopyFrom(ev, aqTempShape);
  227.         else
  228.             updateShape->Union(ev, aqTempShape);
  229.                         
  230.         first = FALSE;
  231.     }
  232.  
  233.     return updateShape;
  234. }
  235.  
  236. //----------------------------------------------------------------------------------------
  237. //    CBaseContent::RedrawProxies
  238. //----------------------------------------------------------------------------------------
  239.  
  240. void CBaseContent::RedrawProxies(Environment* ev)
  241. {
  242.     // Calculate the update shape and invalidate it
  243.     FW_CAcquiredODShape updateShape = CalcUpdateShape(ev);
  244.     if (updateShape != NULL)
  245.     {
  246.         // Invalidate the update shape
  247.         FW_CPresentation* presentation = fContainerPart->GetMainPresentation();
  248.         FW_CFacetClipper facetClipper;
  249.         facetClipper.Clip(ev, presentation, updateShape);
  250.         presentation->Invalidate(ev, updateShape);
  251.     }
  252. }
  253.  
  254. //----------------------------------------------------------------------------------------
  255. //    CBaseContent::PostInternalizeProxy
  256. //----------------------------------------------------------------------------------------
  257.  
  258. void CBaseContent::PostInternalizeProxy(Environment* ev, const FW_CPoint& offset, CProxy* proxy)
  259. {
  260. FW_UNUSED(ev);
  261. FW_UNUSED(offset);
  262. FW_UNUSED(proxy);
  263.     // Default is to do nothing
  264. }
  265.  
  266. //----------------------------------------------------------------------------------------
  267. //    CBaseContent::ExternalizeProxyList
  268. //----------------------------------------------------------------------------------------
  269.  
  270. void CBaseContent::ExternalizeProxyList(Environment* ev,
  271.                                         ODStorageUnit* storageUnit, 
  272.                                         FW_CCloneInfo* cloneInfo,
  273.                                         FW_Fixed offsetX,
  274.                                         FW_Fixed offsetY)
  275. {
  276.     // ----- Create an archive for our proxies -----
  277.     FW_PStorageUnitSink suSink(ev, storageUnit, kODPropContents, fContainerPart->GetPartKind(ev)->GetType(ev));
  278.     FW_CWritableStream archive(suSink);
  279.     
  280.     // ----- Write number of proxies -----
  281.     unsigned long count = fProxyList->Count();
  282.     archive << count;
  283.     
  284.     // ----- Write top, left offsets -----
  285.     archive << offsetX;
  286.     archive << offsetY;
  287.  
  288.     // ----- Write Background Color -----
  289.     archive << fBackgroundColor;
  290.     
  291.     // ----- Write proxies -----
  292.     CProxyCollectionIterator ite(fProxyList);
  293.     FW_CRect frameRect;
  294.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  295.     {
  296.         FW_CRect bounds = proxy->GetBounds(ev);
  297.         archive << bounds;
  298.         proxy->Externalize(ev, suSink->GetStorageUnitView(ev), cloneInfo);
  299.     }    
  300. }
  301.  
  302. //----------------------------------------------------------------------------------------
  303. //    CBaseContent::InternalizeProxyList
  304. //----------------------------------------------------------------------------------------
  305.  
  306. void CBaseContent::InternalizeProxyList(Environment* ev,
  307.                                         ODStorageUnit* storageUnit, 
  308.                                         FW_CCloneInfo* cloneInfo)
  309. {
  310.     // ----- Create an archive for our proxies -----
  311.     FW_PStorageUnitSink suSink(ev, storageUnit, kODPropContents, fContainerPart->GetPartKind(ev)->GetType(ev));
  312.     FW_CReadableStream archive(suSink);
  313.     
  314.     // ----- Read number of proxies -----
  315.     unsigned long count;
  316.     archive >> count;
  317.  
  318.     // ----- Read top left offset -----
  319.     FW_CPoint offset;
  320.     archive >> offset.x;
  321.     archive >> offset.y;
  322.  
  323.     // ----- Read Background Color -----
  324.     archive >> fBackgroundColor;
  325.  
  326.     // ----- Read proxies -----
  327.     FW_CRect frameRect;
  328.     CProxy* proxy;
  329.     for (short i = 0; i<count; i++)
  330.     {
  331.         archive >> frameRect;
  332.         proxy = new CProxy(ev, frameRect, fContainerPart, FW_CPart::fgViewAsFrameToken);
  333.         
  334.         FW_TRY
  335.         {
  336.             proxy->Internalize(ev, suSink->GetStorageUnitView(ev), cloneInfo);
  337.         }
  338.         FW_CATCH_BEGIN
  339.         FW_CATCH_EVERYTHING()
  340.         {
  341.             proxy->Release();
  342.             FW_THROW_SAME();
  343.         }
  344.         FW_CATCH_END
  345.         
  346.         // ----- Add the proxy to the proxy list -----
  347.         this->AddProxy(ev, proxy);
  348.  
  349.         // Now it's in our list, so we can release it. Doing before PostInternalizProxy
  350.         // saves putting another catch block
  351.         proxy->Release();
  352.         
  353.         // ----- Do whatever else needs to be done to the proxy -----
  354.         this->PostInternalizeProxy(ev, offset, proxy);
  355.         
  356.     }
  357. }
  358.  
  359. //----------------------------------------------------------------------------------------
  360. //    CBaseContent::IsDataOnlyOneProxy
  361. //----------------------------------------------------------------------------------------
  362.  
  363. FW_MProxy* CBaseContent::IsDataOnlyOneProxy(Environment* ev) const
  364. {
  365. FW_UNUSED(ev);
  366.     if (CountProxies() == 1)
  367.     {
  368.         return (CProxy*)GetFirstProxy();
  369.     }
  370.     
  371.     return NULL;
  372. }
  373.  
  374. //----------------------------------------------------------------------------------------
  375. //    CBaseContent::AddSingleEmbeddedFrame
  376. //----------------------------------------------------------------------------------------
  377.  
  378. CProxy* CBaseContent::AddSingleEmbeddedFrame(Environment* ev, 
  379.                                                   FW_CEmbeddingFrame* scopeFrame,
  380.                                                   ODPart* embeddedPart, 
  381.                                                   ODFrame* embeddedFrame,
  382.                                                   ODShape* suggestedShape,
  383.                                                   ODTypeToken viewType)
  384. {
  385.     // ----- Calculate the default proxy rect -----
  386.     FW_CRect proxyRect;
  387.     if (suggestedShape)
  388.     {
  389.         proxyRect = FW_GetShapeBoundingBox(ev, suggestedShape);
  390.         proxyRect.Offset(-proxyRect.left, -proxyRect.top);
  391.     }
  392.     else
  393.     {
  394.         proxyRect.SetInt(0, 0, 80, 80);
  395.     }
  396.  
  397.     // ----- Calculate the shape of the embedded frame -----    
  398.     FW_CAcquiredODShape aqFrameShape = ::FW_NewODShape(ev, proxyRect);
  399.     
  400.     // ----- Calculate the position of the embedded frame -----
  401.     // ----- We place it in the middle of the content view -----
  402.     FW_CRect frameBounds = scopeFrame->GetContentView(ev)->GetBoundsInContent(ev);
  403.     proxyRect.PlaceInCenterOf(frameBounds);
  404.     
  405.     // ----- Create the proxy -----
  406.     CProxy* proxy = new CProxy(ev, proxyRect, fContainerPart, viewType);
  407.  
  408.     // Make sure that if an exception occurs before we complete this method,
  409.     // we dispose of the proxy
  410.     FW_TRY
  411.     {
  412.         if (embeddedPart != NULL)
  413.         {
  414.             proxy->EmbedPart(ev, 
  415.                             scopeFrame->GetPresentation(ev),
  416.                             embeddedPart, 
  417.                             kODFrameObject,        // I want persistent frames
  418.                             aqFrameShape,
  419.                             viewType,
  420.                             NULL,        // no presentation
  421.                             0,            // group id
  422.                             FALSE,        // IsOverlaid
  423.                             FALSE);        // sub frame
  424.         }
  425.         else
  426.         {
  427.             proxy->EmbedFrame(ev, 
  428.                             scopeFrame,
  429.                             embeddedFrame,
  430.                             aqFrameShape,
  431.                             viewType);
  432.         }
  433.     }
  434.     FW_CATCH_BEGIN
  435.     FW_CATCH_EVERYTHING () {
  436.         // cleanup in case the Embed failed
  437.         proxy->Release();
  438.         FW_THROW_SAME ();
  439.     }
  440.     FW_CATCH_END
  441.  
  442.     // ----- Add the proxy to our list -----
  443.     this->AddProxy(ev, proxy);
  444.     
  445.     return proxy;
  446. }
  447.  
  448. //========================================================================================
  449. //    class CContentProxyIterator
  450. //========================================================================================
  451.  
  452. //----------------------------------------------------------------------------------------
  453. //    CContentProxyIterator::CContentProxyIterator
  454. //----------------------------------------------------------------------------------------
  455.  
  456. CContentProxyIterator::CContentProxyIterator(CBaseContent* content) :
  457.     CProxyCollectionIterator(content->fProxyList)
  458. {
  459.     FW_END_CONSTRUCTOR
  460. }
  461.  
  462. //----------------------------------------------------------------------------------------
  463. //    CContentProxyIterator::~CContentProxyIterator
  464. //----------------------------------------------------------------------------------------
  465.  
  466. CContentProxyIterator::~CContentProxyIterator()
  467. {
  468.     FW_START_DESTRUCTOR
  469. }
  470.  
  471. //========================================================================================
  472. //    class CPartContent
  473. //========================================================================================
  474.  
  475. //----------------------------------------------------------------------------------------
  476. //    CPartContent::CPartContent
  477. //----------------------------------------------------------------------------------------
  478. //    CPartContent constructor
  479.  
  480. CPartContent::CPartContent(Environment* ev, CContainerPart* part)
  481. :    CBaseContent(ev, part)
  482. {
  483.     FW_END_CONSTRUCTOR
  484. }
  485.  
  486. //----------------------------------------------------------------------------------------
  487. //    CPartContent::~CPartContent
  488. //----------------------------------------------------------------------------------------
  489. //    CPartContent destructor
  490.  
  491. CPartContent::~CPartContent()
  492. {
  493.     FW_START_DESTRUCTOR
  494. }
  495.  
  496. //----------------------------------------------------------------------------------------
  497. //    CPartContent::ExternalizeKind
  498. //----------------------------------------------------------------------------------------
  499.  
  500. void CPartContent::ExternalizeKind(Environment* ev,
  501.                                 ODStorageUnit* storageUnit, 
  502.                                 FW_CKind* kind,
  503.                                 FW_StorageKinds storageKind,
  504.                                 FW_CPromise* promise,
  505.                                 FW_CCloneInfo* cloneInfo)
  506. {
  507. FW_UNUSED(storageKind);
  508. FW_UNUSED(promise);
  509. FW_UNUSED(kind);
  510.     FW_ASSERT(kind->IsPartKind(ev));
  511.     
  512.     ExternalizeProxyList(ev, storageUnit, cloneInfo, FW_kFixed0, FW_kFixed0);
  513. }
  514.  
  515. //----------------------------------------------------------------------------------------
  516. //    CPartContent::Internalize
  517. //----------------------------------------------------------------------------------------
  518.  
  519. FW_Boolean CPartContent::InternalizeKind(Environment* ev,
  520.                                     ODStorageUnit* storageUnit, 
  521.                                     FW_CKind* kind,
  522.                                     FW_StorageKinds storageKind,
  523.                                     FW_CCloneInfo* cloneInfo)
  524. {    
  525. FW_UNUSED(kind);
  526. FW_UNUSED(storageKind);
  527.     InternalizeProxyList(ev, storageUnit, cloneInfo);
  528.     return true;
  529. }
  530.  
  531. //----------------------------------------------------------------------------------------
  532. //    CPartContent::PostInternalizeProxy
  533. //----------------------------------------------------------------------------------------
  534.  
  535. void CPartContent::PostInternalizeProxy(Environment* ev, const FW_CPoint& offset, CProxy* proxy)
  536. {
  537.     if (offset != FW_kZeroPoint)
  538.         proxy->OffsetProxy(ev, -offset.x, -offset.y);
  539. }
  540.  
  541. //========================================================================================
  542. //    class CSelectionContent
  543. //========================================================================================
  544.  
  545. //----------------------------------------------------------------------------------------
  546. //    CSelectionContent::CSelectionContent
  547. //----------------------------------------------------------------------------------------
  548. //    CSelectionContent constructor
  549.  
  550. CSelectionContent::CSelectionContent(Environment* ev, CContainerPart* part, CContainerSelection* selection)
  551. :    CBaseContent(ev, part),
  552.     fContainerSelection(selection)
  553. {
  554.     FW_END_CONSTRUCTOR
  555. }
  556.  
  557. //----------------------------------------------------------------------------------------
  558. //    CSelectionContent::~CSelectionContent
  559. //----------------------------------------------------------------------------------------
  560. //    CSelectionContent destructor
  561.  
  562. CSelectionContent::~CSelectionContent()
  563. {
  564.     FW_START_DESTRUCTOR
  565. }
  566.  
  567. //----------------------------------------------------------------------------------------
  568. //    CSelectionContent::InternalizeKind
  569. //----------------------------------------------------------------------------------------
  570.  
  571. FW_Boolean CSelectionContent::InternalizeKind(Environment* ev,
  572.                                           ODStorageUnit* storageUnit, 
  573.                                           FW_CKind* kind,
  574.                                           FW_StorageKinds storageKind,
  575.                                           FW_CCloneInfo* cloneInfo)
  576. {
  577. FW_UNUSED(kind);
  578. FW_UNUSED(storageKind);
  579.     // ----- Read in the proxies -----
  580.     InternalizeProxyList(ev, storageUnit, cloneInfo);
  581.     
  582.     return true;
  583. }
  584.  
  585. //----------------------------------------------------------------------------------------
  586. //    CSelectionContent::ExternalizeKind
  587. //----------------------------------------------------------------------------------------
  588.  
  589. void CSelectionContent::ExternalizeKind(Environment* ev,
  590.                                     ODStorageUnit* storageUnit, 
  591.                                     FW_CKind* kind,
  592.                                     FW_StorageKinds storageKind,
  593.                                     FW_CPromise* promise,
  594.                                     FW_CCloneInfo* cloneInfo)
  595. {
  596. FW_UNUSED(kind);
  597. FW_UNUSED(storageKind);
  598. FW_UNUSED(promise);
  599.     FW_ASSERT(kind->IsPartKind(ev));
  600.     
  601.     FW_CRect selectRect = fContainerSelection->GetDragRect(ev);
  602.  
  603.     ExternalizeProxyList(ev, storageUnit, cloneInfo, selectRect.left, selectRect.top);
  604. }
  605.  
  606. //----------------------------------------------------------------------------------------
  607. //    CSelectionContent::IncorporateEmbeddedFrame
  608. //----------------------------------------------------------------------------------------
  609.  
  610. void CSelectionContent::IncorporateEmbeddedFrame(Environment* ev, 
  611.                                                 FW_CEmbeddingFrame* scopeFrame,
  612.                                                 ODFrame* embeddedFrame,
  613.                                                 ODShape* suggestedShape,
  614.                                                 ODTypeToken viewType)
  615. {
  616.     CProxy* insertedProxy = AddSingleEmbeddedFrame(ev, 
  617.                                                     scopeFrame, 
  618.                                                     NULL, 
  619.                                                     embeddedFrame, 
  620.                                                     suggestedShape, 
  621.                                                     viewType);    
  622.                                                     
  623.     PostInternalizeProxy(ev, FW_kZeroPoint, insertedProxy);
  624.     insertedProxy->Release();
  625. }
  626.  
  627. //----------------------------------------------------------------------------------------
  628. //    CSelectionContent::IncorporateEmbeddedPart
  629. //----------------------------------------------------------------------------------------
  630.  
  631. void CSelectionContent::IncorporateEmbeddedPart(Environment* ev, 
  632.                                                 FW_CEmbeddingFrame* scopeFrame,
  633.                                                 ODPart* embeddedPart, 
  634.                                                 ODShape* suggestedShape,
  635.                                                 ODTypeToken viewType)
  636. {
  637.     CProxy* insertedProxy = AddSingleEmbeddedFrame(ev, 
  638.                                                     scopeFrame, 
  639.                                                     embeddedPart, 
  640.                                                     NULL, 
  641.                                                     suggestedShape, 
  642.                                                     viewType);    
  643.                                                     
  644.     PostInternalizeProxy(ev, FW_kZeroPoint, insertedProxy);                                        
  645.     insertedProxy->Release();
  646. }
  647.  
  648. //----------------------------------------------------------------------------------------
  649. //    CSelectionContent::PostInternalizeProxy
  650. //----------------------------------------------------------------------------------------
  651.  
  652. void CSelectionContent::PostInternalizeProxy(Environment* ev, const FW_CPoint& offset, CProxy* proxy)
  653. {
  654. FW_UNUSED(offset);
  655.     // ----- Add the proxy to the right places -----
  656.     fContainerPart->AddProxyToPart(ev, proxy);    // Add to the part data
  657.     
  658.     // ----- Proxy has already been added to the selection list (fProxyList)
  659.     fContainerSelection->ProxyAdded(ev, proxy);
  660. }
  661.  
  662. //----------------------------------------------------------------------------------------
  663. //    CSelectionContent::AcquireSuggestedFrameShape
  664. //----------------------------------------------------------------------------------------
  665.  
  666. ODShape* CSelectionContent::AcquireSuggestedFrameShape(Environment* ev)
  667. {
  668.     FW_CRect selectionRect = fContainerSelection->GetDragRect(ev);
  669.     selectionRect.Place(FW_kZeroPoint);
  670.     
  671.     return ::FW_NewODShape(ev, selectionRect);
  672. }
  673.  
  674. //========================================================================================
  675. //    class CUndoContent
  676. //========================================================================================
  677.  
  678. //----------------------------------------------------------------------------------------
  679. //    CUndoContent::CUndoContent
  680. //----------------------------------------------------------------------------------------
  681. //    CUndoContent constructor
  682.  
  683. CUndoContent::CUndoContent(Environment* ev, CContainerSelection* selection) :
  684.     CBaseContent(ev, selection->GetSelectionContent(ev)),
  685.     fContainerSelection(selection)
  686. {
  687.     FW_END_CONSTRUCTOR
  688. }
  689.  
  690. //----------------------------------------------------------------------------------------
  691. //    CUndoContent::~CUndoContent
  692. //----------------------------------------------------------------------------------------
  693. //    CUndoContent destructor
  694.  
  695. CUndoContent::~CUndoContent()
  696. {
  697.     FW_START_DESTRUCTOR
  698. }
  699.  
  700. //----------------------------------------------------------------------------------------
  701. //    CUndoContent::RemoveProxySelection
  702. //----------------------------------------------------------------------------------------
  703.  
  704. void CUndoContent::RemoveProxySelection(Environment* ev)
  705. {
  706.     // Select the saved proxies
  707.     fContainerSelection->SelectContent(ev, this);
  708.  
  709.     // Clear the selected proxies
  710.     fContainerSelection->ClearSelection(ev);
  711.  
  712. }
  713.  
  714. //----------------------------------------------------------------------------------------
  715. //    CUndoContent::RestoreProxySelection
  716. //----------------------------------------------------------------------------------------
  717.  
  718. void CUndoContent::RestoreProxySelection(Environment* ev)
  719. {
  720.     // Add the saved proxies back into the part
  721.     CContentProxyIterator ite(this);
  722.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  723.     {
  724.         fContainerPart->AttachProxy(ev, proxy);
  725.     }
  726.  
  727.     // Redraw the restored proxies
  728.     RedrawProxies(ev);
  729.  
  730.     // Select the saved proxies
  731.     fContainerSelection->SelectContent(ev, this);
  732. }
  733.  
  734. //----------------------------------------------------------------------------------------
  735. //    CUndoContent::CommitPasteDone
  736. //----------------------------------------------------------------------------------------
  737.  
  738. void  CUndoContent::CommitPasteDone(Environment* ev)
  739. {
  740.     CContentProxyIterator ite(this);
  741.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  742.     {
  743.         proxy->CommitPasteDone(ev);
  744.     }
  745. }
  746.  
  747.  
  748.